package thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        Doo doo = new Doo();
        Thread t1 = new Thread("sss"){
            @Override
            public void run() {
                doo.doSomething();
            }
        };
        Thread t2 = new Thread("zzz"){
            @Override
            public void run() {
                Doo.doSomething();
            }
        };
        t1.start();
        t2.start();

    }
}
class Doo{
    public synchronized static void doSomething(){
        synchronized (Doo.class){
            Thread t = Thread.currentThread();

            System.out.println(t.getName() + "正在执行do...方法");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            System.out.println("方法执行完毕");
        }
    }
}